use serde::{Deserialize, Serialize};

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Output<T> {
    pub status_code: i32,
    pub error_code: i32,
    pub message: String,
    pub data: Option<T>,
}

impl<T> Output<T> {
    pub fn success(message: String, data: Option<T>) -> Self {
        Output {
            status_code: 200,
            error_code: 0,
            message,
            data,
        }
    }

    pub fn failure(error_code: i32, message: String) -> Self {
        Output {
            status_code: 500,
            error_code,
            message,
            data: None,
        }
    }
}
